package com.ruoyi.project.remoteControl.service.impl;

import com.ruoyi.project.remoteControl.domain.TugBoatInfo;
import com.ruoyi.project.remoteControl.domain.Option;
import com.ruoyi.project.remoteControl.mapper.DeviceAliveInfoMapper;
import com.ruoyi.project.remoteControl.service.OptionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

@Service
public class OptionServiceImpl implements OptionService {
    @Autowired
    DeviceAliveInfoMapper deviceAliveInfoMapper;
    
    /**
     * 获取拖轮信息并封装成Option对象列表
     * @return
     */
    @Override
    public List<Option> getTugboatOption() {
        List<TugBoatInfo> tugBoatInfoList = deviceAliveInfoMapper.selectAllTugboatInfo();
        List<Option> deviceOption = new ArrayList<>();
        for (TugBoatInfo tugBoatInfo : tugBoatInfoList){
            Option option = new Option();
            option.setKey(tugBoatInfo.getDeviceClientId());
            option.setValue(tugBoatInfo.getDeviceClientId());
            option.setLabel(tugBoatInfo.getDeviceName());
            deviceOption.add(option);
        }
        return deviceOption;
    }
}
